﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using anks.Components;

namespace pygs.Messaging.Transport
{
    public abstract class CustomTransport : Component
    {
        public class SendingError : Exception
        {
        }
        
        public class SendingResult
        {
            private List<Message> _sended = new List<Message>();
            private List<Message> _failed = new List<Message>();
            private List<SendingError> _errors = new List<SendingError>();

            public IEnumerable<Message> sended { get { return _sended; } }
            public IEnumerable<Message> failed { get { return _failed; } }
            public IEnumerable<SendingError> errors { get { return _errors; } }

            public void AddSended(Message message)
            {
                _sended.Add(message);
            }

            public void AddSended(IEnumerable<Message> list)
            {
                _sended.AddRange(list);
            }

            public void AddFailed(Message message)
            {
                _failed.Add(message);
            }

            public void AddFailed(IEnumerable<Message> list)
            {
                _failed.AddRange(list);
            }

            public void AddError(SendingError error)
            {
                _errors.Add(error);
            }

            public void AddError(IEnumerable<SendingError> list)
            {
                _errors.AddRange(list);
            }
        }

        public abstract bool Send(List<Message> list, out SendingResult result);
    }
}
